package com.woniuxy.factory.controller;

import com.woniuxy.factory.entity.MaterialOut;
import com.woniuxy.factory.entity.ResponseResult;
import com.woniuxy.factory.service.MaterialOutService;
import com.woniuxy.factory.util.AuditType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author 邹佳骏
 * @date 2020-08-21 16:13
 */
@Controller
public class MaterialOutController {

    @Autowired
    MaterialOutService materialOutService;

    @ResponseBody
    @GetMapping("/materialout")
    public ResponseResult<List<MaterialOut>> getAllMaterialOut(int page,int limit
        ,MaterialOut materialOut,String matId,String searchTime){
        ResponseResult<List<MaterialOut>>  responseResult = new ResponseResult<>();
        materialOutService.selectAllCount();
        List<MaterialOut> materialOuts = materialOutService.selectAllMaterialOut(page,limit,materialOut,matId,searchTime);
        int count = materialOutService.selectAllCount();
        responseResult.setMsg("查询成功");
        responseResult.setCode(AuditType.No_Approval);
        responseResult.setData(materialOuts);
        responseResult.setCount(count);
        return responseResult;
    }


    @ResponseBody
    @RequestMapping("/updatematerialout")
    public ResponseResult updatMaterialOut(MaterialOut materialOut,String matId){
        ResponseResult responseResult = materialOutService.updatMaterialOut(materialOut, matId);
        return responseResult;
    }
}
